<template>
    <div class="upd">
        <el-row class="head">
            <el-col >——更改维修分类/维修分类</el-col>
        </el-row>
        <el-row class="title">
            <el-col>更改维修分类</el-col>
        </el-row>
        <el-form :model="form" label-width="130px" :rules="rules" ref="ruleform" >
            <el-form-item label="分类名称"  prop="name">
                <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="自动完成时间">
                <el-input-number v-model="form.autoCompleteHours"  :min="1"  ></el-input-number> 小时
            </el-form-item>
            <el-form-item label="用户默认评价">
                <el-input-number v-model="form.autoCompleteStars"  :min="1" :max="5" ></el-input-number> 星
            </el-form-item>
            <el-form-item label="允许用户创建">
                <el-radio v-model="form.allowUserCreate" :label="true">是</el-radio>
                <el-radio v-model="form.allowUserCreate" :label="false">否</el-radio>
            </el-form-item>
            <el-form-item label="必填报障人信息">
                <el-radio v-model="form.needUserInfo" :label="true">是</el-radio>
                <el-radio v-model="form.needUserInfo" :label="false">否</el-radio>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    export default {
        name: "upd",
        data(){
            return{
                form:{
                },
                data:{
                    id:this.$route.params.id
                },
                rules: {
                    name: [
                        {required: true, message: '请输入活动名称', trigger: 'blur'},
                        {min: 2, max: 18, message: '长度在 2 到 18 个字符', trigger: 'blur'}
                    ],
                }
            }
        },
        created()
        {

            this.$axios.post("/api/v1/super/type/typeId",this.data)
                .then(result=>{
                    return result.data
                })
                .then(data=> {
                    console.log(data.data);
                   this.form=data.data;
                });
        },
        methods:{
            onSubmit(){
                this.$refs.ruleform.validate((valid) => {
                    if (valid) {
                        this.$axios.post("/api/v1/super/type/update",this.form)
                            .then(result=>{
                                return result.data
                            })
                            .then(data=>{
                                this.$message(
                                    {
                                        message:"更新成功",
                                        type:"success"
                                    }
                                );
                                this.$router.push({
                                    path:`/columns/list`
                                })
                            })
                    } else {
                        return false;
                    }
                });

            }
        }
    }
</script>

<style scoped>
    .el-input{
        width: 600px;
    }
</style>